//
//  RSCommonFooterView.m
//  RenShineDoctor
//
//  Created by 黄强强 on 15/11/6.
//  Copyright © 2015年 杭州岐黄信息技术有限公司. All rights reserved.
//

#import "HQQSettingFooterView.h"
#import "HQQSettingConfig.h"
#import <HQQCommonTools.h>

@interface HQQSettingFooterView ()
@property (nonatomic, weak) UIButton *titleBtn;
@end

@implementation HQQSettingFooterView

+ (instancetype)footerView
{
    return [[self alloc] init];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.hqq_width = [UIScreen mainScreen].bounds.size.width;
        
        UIButton *titleBtn = [[UIButton alloc] init];
        titleBtn.layer.cornerRadius = 5.0;
        titleBtn.layer.masksToBounds = YES;
        
        titleBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [titleBtn setTitle:HQQSettingFooterViewTitle forState:UIControlStateNormal];
        [titleBtn setTitleColor:HQQSettingFooterViewTitleColor forState:UIControlStateNormal];
        [titleBtn setBackgroundColor:HQQSettingFooterViewBackgroundColor];
        
        titleBtn.hqq_width = self.hqq_width - 2 * HQQSettingFooterViewLeftRightMargin;
        titleBtn.hqq_height = 44;
        
        [titleBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:titleBtn];
        self.titleBtn = titleBtn;
        
        self.hqq_height = self.titleBtn.hqq_height + 2 * HQQSettingFooterViewTopBottomMargin;
        titleBtn.center = CGPointMake(self.hqq_width / 2, self.hqq_height / 2);
    }
    return self;
}

- (void)btnClick
{
    if (self.operation) {
        self.operation();
    }
}

@end
